package util

import (
	"encoding/hex"
	"fmt"
	"os"
)

// GetHexStringByFilePath hexadecimal
func GetHexStringByFilePath(path string) (string, error) {
	// 读取文件
	// path := "C:\\Users\\exler\\Desktop\\ali_mts_key"
	file, err := os.ReadFile(path)
	if err != nil {
		fmt.Println(err)
		return "", err
	}

	// hex
	h := GetHexStringByByte(file)
	fmt.Println(h)
	return h, nil
}

func GetHexStringByByte(data []byte) string {
	fmt.Println(data)
	h := hex.EncodeToString(data)
	return h
}

func GetHexBytesByString(data string) ([]byte, error) {
	fmt.Println(data)
	h, err := hex.DecodeString(data)
	return h, err
}
